<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <!-- es6 -->
    <script>
        // 数组的合并
        let kuaizi = ['a', 'b'];
        let feng = ['c', "d"]
        let he = [...kuaizi, ...feng]
        let arr = [10, 20]
        arr.push(...feng)
        // 对象的扩展
        const obj1 = {
            name: 'frontend',
            age: 1
        }
        const obj2 = {
            name: 'diveng',
            time: 2023
        }
        const res = { ...obj1, ...obj2 }
        console.log(res)

        // 数组应用
        const arr = [2024, 2, 3, 66, 100]
        const min = Math.min(...arr)
        const max = Math.max(...arr)

        const name = 'diveng'
        const strarr = [...name]
        console.log(strarr)
        //['d','i','v','e','n','g']


        const nodelist = document.querySelectorAll('div'); //nodelist是类似数组的对象
        const array = [...nodelist]


        // es6
        let myfn = function (num1, num2) {
            console.log(num1, num2)
        }
        myfn(10, 20)
        // js 5 有默认参数
        function show() {
            // arguments 是一个类似数组的对象,默认接收所有的传的参数
            console.log(arguments, arguments[0])
        }
        show(10, 20, 30)
        // ... 不管传来多少参数,参数的值,放到num2 里边,直接是数组
        let myfn2 = function (...num2) {
            console.log(num2)
        }
        // rest参数 可以和确定
        let myfn3 = function (name, ...num2) {
            console.log(name, num2)
        }
        myfn2('张三', 20, 20)
        myfn2('张三')


        myfn3('张三', 20, 20)
        myfn3('张三')
    </script>
</body>

</html>